package com.yugao.fintech.antelope.base.tenant;

import com.yugao.fintech.antelope.base.model.module.tenant.TenantContextHolder;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Component
@Aspect
public class SpringRabbitMqListenerAspect {

    @Around("@annotation(org.springframework.amqp.rabbit.annotation.RabbitListener) " +
            "|| @annotation(org.springframework.amqp.rabbit.annotation.RabbitHandler)")
    public Object handle(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        try {
            return proceedingJoinPoint.proceed();
        } finally {
            TenantContextHolder.clear();
        }
    }
}
